import statement
Enhancing Project-Specific Code Completion by Inferring Internal API Information
Deng, Le, Ren, Xiaoxue, Ni, Chao, Liang, Ming, Lo, David, Liu, Zhongxin
Project-specific code completion is a critical task that leverages context from a project to generate accurate code. State-of-the-art methods use retrieval-augmented generation (RAG) with large language models (LLMs) and project information for code completion. However, they often struggle to incorporate internal API information, which is crucial for accuracy, especially when APIs are not explicitly imported in the file. To address this, we propose a method to infer internal API information without relying on imports. Our method extends the representation of APIs by constructing usage examples and semantic descriptions, building a knowledge base for LLMs to generate relevant completions. We also introduce ProjBench, a benchmark that avoids leaked imports and consists of large-scale real-world projects. Experiments on ProjBench and CrossCodeEval show that our approach significantly outperforms existing methods, improving code exact match by 22.72% and identifier exact match by 18.31%. Additionally, integrating our method with existing baselines boosts code match by 47.80% and identifier match by 35.55%.
ZS4C: Zero-Shot Synthesis of Compilable Code for Incomplete Code Snippets using ChatGPT
Kabir, Azmain, Wang, Shaowei, Tian, Yuan, Tse-Hsun, null, Chen, null, Asaduzzaman, Muhammad, Zhang, Wenbin
Technical question and answering (Q&A) sites such as Stack Overflow have become an important source for software developers to seek knowledge. However, code snippets on Q&A sites are usually uncompilable and semantically incomplete for compilation due to unresolved types and missing dependent libraries, which raises the obstacle for users to reuse or analyze Q&A code snippets. Prior approaches either are not designed for synthesizing compilable code or suffer from a low compilation success rate. To address this problem, we propose ZS4C, a lightweight approach to perform zero-shot synthesis of compilable code from incomplete code snippets using Large Language Model (LLM). ZS4C operates in two stages. In the first stage, ZS4C utilizes an LLM, i.e., ChatGPT, to identify missing import statements for a given code snippet, leveraging our designed task-specific prompt template. In the second stage, ZS4C fixes compilation errors caused by incorrect import statements and syntax errors through collaborative work between ChatGPT and a compiler. We thoroughly evaluated ZS4C on a widely used benchmark called StatType-SO against the SOTA approach SnR. Compared with SnR, ZS4C improves the compilation rate from 63% to 87.6%, with a 39.3% improvement. On average, ZS4C can infer more accurate import statements than SnR, with an improvement of 6.6% in the F1.
How GitHub Copilot Simplified My Life as a Data Scientist
If you have been following the recent tech news, you might have heard about GitHub Copilot, an AI-based programming assistant. It's well and good if you are already using it, if not, keep reading! I have been using GitHub Copilot for a few months now, and I absolutely love it. In this article, I will try to make a convincing statement so that you give the Copilot a shot. You might fall in love too!
Building a REST API in Java and Scala Using Play Framework - Part 2
In the first part of this series, we introduced Play framework, a web development framework for Java and Scala developers, and we showed how it enabled one to expose a basic REST API with minimal effort. In this second part, we explore some of the features of Play and use real code to illustrate its capabilities. Play supports both synchronous and asynchronous REST services, and it's particularly powerful when dealing with asynchronous requests. Whatever the request, an Action always returns an instance of play.mvc.Result. This can be directly returned to the consumer in the case of a synchronous service, or it can be served up as a Future.
Structuring Your Project -- The Hitchhiker's Guide to Python
By "structure" we mean the decisions you make concerning how your project best meets its objective. We need to consider how to best leverage Python's features to create clean, effective code. In practical terms, "structure" means making clean code whose logic and dependencies are clear as well as how the files and folders are organized in the filesystem. Which functions should go into which modules? How does data flow through the project? What features and functions can be grouped together and isolated? By answering questions like these you can begin to plan, in a broad sense, what your finished product will look like. In this section we take a closer look at Python's module and import systems as they are the central elements to enforcing structure in your project.
Import2vec - Learning Embeddings for Software Libraries
Theeten, Bart, Vandeputte, Frederik, Van Cutsem, Tom
We consider the problem of developing suitable learning representations (embeddings) for library packages that capture semantic similarity among libraries. Such representations are known to improve the performance of downstream learning tasks (e.g. classification) or applications such as contextual search and analogical reasoning. We apply word embedding techniques from natural language processing (NLP) to train embeddings for library packages ("library vectors"). Library vectors represent libraries by similar context of use as determined by import statements present in source code. Experimental results obtained from training such embeddings on three large open source software corpora reveals that library vectors capture semantically meaningful relationships among software libraries, such as the relationship between frameworks and their plug-ins and libraries commonly used together within ecosystems such as big data infrastructure projects (in Java), front-end and back-end web development frameworks (in JavaScript) and data science toolkits (in Python).
Python libraries and packages for Data Scientists (Top 5)
Did you know that Python wasn't originally built for Data Science? It's an open-source language, and data professionals started creating tools for it to complete data tasks more efficiently. Here, I'll introduce the most important Python libraries and packages that you have to know as a Data Scientist. In my previous article, I introduced the Python import statement and the most important modules from the Python Standard Library. In this one, I'll focus on the libraries and packages that are not coming with Python 3 by default.